package com.jinwei.qunguanjia.web.system.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

@Data
public class DeptTreeSelectVO {
    /** 节点ID */
    private String id;

    /** 节点名称 */
    private String label;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<DeptTreeSelectVO> children;

    public DeptTreeSelectVO(SysDeptVO dept) {
        this.id = dept.getDeptId();
        this.label = dept.getDeptName();
        if (null != dept.getChildren()) {
            this.children = dept.getChildren().stream().map(DeptTreeSelectVO::new).collect(Collectors.toList());
        }
    }
}
